
set(COMPONENT_SRCS "audio_spiffs.c" "audio_i2s.c" "audio_player.c" "audio_tts.c" "wakeword.c" "wav_decoder.c" "wav_encoder.c")  

set(COMPONENT_ADD_INCLUDEDIRS ". include")

set(COMPONENT_REQUIRES driver spiffs vfs freertos espressif__esp-sr hal_drive wifi)

# set(COMPONENT_EMBED_TXTFILES POWER_ON.pcm)

register_component()

### 手动烧写指令：
# source flash_voicedata.sh managed_components/espressif__esp-sr/esp-tts/esp_tts_chinese/esp_tts_voice_data_xiaole.dat  /dev/ttyACM0
# source flash_voicedata.sh managed_components/espressif__esp-sr/esp-tts/esp_tts_chinese/esp_tts_voice_data_xiaoxin_small.dat  /dev/ttyACM0

### 使能会自动把 esp_tts_voice_data_xiaole.dat 烧写到tts分区表中！
if (0)  
#### 设置TTS路径
# Determine whether esp-sr is fetched from component registry or from local path
idf_build_get_property(build_components BUILD_COMPONENTS)
if(esp-sr IN_LIST build_components)
    set(esp-sr_name esp-sr) # Local component
else()
    set(esp-sr_name espressif__esp-sr) # Managed component
endif()

# Get path to voice data file
idf_component_get_property(esp-sr_path ${esp-sr_name} COMPONENT_DIR)
# set(tts_image ${esp-sr_path}/esp-tts/esp_tts_chinese/esp_tts_voice_data_xiaoxin.dat)
# set(tts_image ${esp-sr_path}/esp-tts/esp_tts_chinese/esp_tts_voice_data_xiaoxin_small.dat)
set(tts_image ${esp-sr_path}/esp-tts/esp_tts_chinese/esp_tts_voice_data_xiaole.dat)
add_custom_target(tts ALL DEPENDS ${tts_image})
add_dependencies(flash tts)

partition_table_get_partition_info(size "--partition-name tts" "size")
partition_table_get_partition_info(offset "--partition-name tts" "offset")

if("${size}" AND "${offset}")
    esptool_py_flash_to_partition(flash "tts" "${tts_image}")
else()
    set(message "Failed to find model in partition table file"
                "Please add a line(Name=tts, Type=data, Size=3890K) to the partition file.")
endif()
endif()